{% for stylesheet in localcss %}
    <link rel="stylesheet" type="text/css" href="{{ stylesheet }}"/>
{% endfor %}
{% for script in localjs %}
    <script src="{{ script }}"></script>
{% endfor %}

<div id="content-wrapper">
    <div id="viewer" class="pdfViewer"></div>
</div>

<script>
    window['csrfToken'] = "{{ csrfToken }}";
    try {
        for(let i = 0 ; i < localStorage.length; i++){
            if(localStorage.key(i).includes('annotations')){
                localStorage.removeItem(localStorage.key(i));
            }
        }
        let annotations = JSON.parse({{ annotation_jsons|json_encode|raw }});
        for(let grader in annotations){
            if(annotations[grader] !== ""){
                localStorage.setItem('{{ filename }}/' + grader +'/annotations', annotations[grader]);
            }
        }
    }
    catch (err) {
        console.error(err);
        alert("Can't fetch annotations");
    }
    {% if student_popup %}
    render_student("{{ gradeable_id }}", "{{ user_id }}", "{{ filename }}", "{{ pdf_url_base | raw}}");
    {% else %}
    render("{{ gradeable_id }}", "{{ user_id }}", "{{ grader_id }}", '{{ filename }}', {{ page_num }});
    {% endif %}
</script>
